<@html>
<script type="text/javascript">
	dojo.require("dijit.dijit");
	dojo.require("dijit.form.Form");
	dojo.require("dijit.form.DateTextBox");
	dojo.require("dijit.form.Button");
	dojo.require("dijit.form.ValidationTextBox");
</script>
<@queryForm>
<table>
			<tr>
<td>
<@s.text name="code"/>：
</td>
<td>
	<input type="hidden" name="condition[0].propertyName" value="code"/>
	<input type="hidden" name="condition[0].operator" value="LIKE"/>
	<input type="hidden" name="condition[0].matchMode" value="BEFORE"/>
	<input id="code" name="condition[0].value" dojoType="dijit.form.ValidationTextBox" />
</td>
<td>
<@s.text name="sendTime"/>：
</td>
<td>
	<input type="hidden" name="condition[1].propertyName" value="sendTime"/>
	<input type="hidden" name="condition[1].operator" value="LIKE"/>
	<input type="hidden" name="condition[1].matchMode" value="BEFORE"/>
	<input id="sendTime" name="condition[1].value" dojoType="dijit.form.DateTextBox" />
</td>
<td>
<@s.text name="subject"/>：
</td>
<td>
	<input type="hidden" name="condition[2].propertyName" value="subject"/>
	<input type="hidden" name="condition[2].operator" value="LIKE"/>
	<input type="hidden" name="condition[2].matchMode" value="BEFORE"/>
	<input id="subject" name="condition[2].value" dojoType="dijit.form.ValidationTextBox" />
</td>
			</tr>
			<tr>
<td>
<@s.text name="content"/>：
</td>
<td>
	<input type="hidden" name="condition[3].propertyName" value="content"/>
	<input type="hidden" name="condition[3].operator" value="LIKE"/>
	<input type="hidden" name="condition[3].matchMode" value="BEFORE"/>
	<input id="content" name="condition[3].value" dojoType="dijit.form.ValidationTextBox" />
</td>
<td>
<@s.text name="senderCode"/>：
</td>
<td>
	<input type="hidden" name="condition[4].propertyName" value="senderCode"/>
	<input type="hidden" name="condition[4].operator" value="LIKE"/>
	<input type="hidden" name="condition[4].matchMode" value="BEFORE"/>
	<input id="senderCode" name="condition[4].value" dojoType="dijit.form.ValidationTextBox" />
</td>
<td>
<@s.text name="senderName"/>：
</td>
<td>
	<input type="hidden" name="condition[5].propertyName" value="senderName"/>
	<input type="hidden" name="condition[5].operator" value="LIKE"/>
	<input type="hidden" name="condition[5].matchMode" value="BEFORE"/>
	<input id="senderName" name="condition[5].value" dojoType="dijit.form.ValidationTextBox" />
</td>
			</tr>
			<tr>
<td>
<@s.text name="isDeleted"/>：
</td>
<td>
	<input type="hidden" name="condition[6].propertyName" value="isDeleted"/>
	<input type="hidden" name="condition[6].operator" value="LIKE"/>
	<input type="hidden" name="condition[6].matchMode" value="BEFORE"/>
	<input id="isDeleted" name="condition[6].value" dojoType="dijit.form.ValidationTextBox" />
</td>
<td>
<@s.text name="msgType"/>：
</td>
<td>
	<input type="hidden" name="condition[7].propertyName" value="msgType"/>
	<input type="hidden" name="condition[7].operator" value="LIKE"/>
	<input type="hidden" name="condition[7].matchMode" value="BEFORE"/>
	<input id="msgType" name="condition[7].value" dojoType="dijit.form.ValidationTextBox" />
</td>
</table>

<div id="seniorQueryCondition" title="高级查询条件">
</div>
</@queryForm>
<@toolbar/>
<link rel="stylesheet" href="${(path)!}/js/dojo/dojox/grid/resources/${(theme)!}Grid.css">
<script type="text/javascript" language="javascript">
	dojo.require("dojox.data.QueryReadStore");
	dojo.require("widget.navgrid.NavGrid");
</script>
<table id="grid" dojoType="widget.navgrid.NavGrid"
	   selectionMode="single" rowsPerPage="10"
	   structure="layout" autoHeight="true">
</table>
</@html>
<script language="javascript" type="text/javascript">
	var store = new dojox.data.QueryReadStore({
		url : "${(path)!}/system/messages.list.do",
		requestMethod : "post"
	});
	var layout = [
		{
		},
		{
			cells : [
				[
{
		name : "<@s.text name="code"/>"
		,field : "code"
		,width:"12%"
		,headerClasses:"gridHeader"
		}			,{
		name : "<@s.text name="sendTime"/>"
		,field : "sendTime"
		,width:"12%"
		,headerClasses:"gridHeader"
		}			,{
		name : "<@s.text name="subject"/>"
		,field : "subject"
		,width:"12%"
		,headerClasses:"gridHeader"
		}			,{
		name : "<@s.text name="content"/>"
		,field : "content"
		,width:"12%"
		,headerClasses:"gridHeader"
		}			,{
		name : "<@s.text name="senderCode"/>"
		,field : "senderCode"
		,width:"12%"
		,headerClasses:"gridHeader"
		}			,{
		name : "<@s.text name="senderName"/>"
		,field : "senderName"
		,width:"12%"
		,headerClasses:"gridHeader"
		}			,{
		name : "<@s.text name="isDeleted"/>"
		,field : "isDeleted"
		,width:"12%"
		,headerClasses:"gridHeader"
		}			,{
		name : "<@s.text name="msgType"/>"
		,field : "msgType"
		,width:"12%"
		,headerClasses:"gridHeader"
		}				]
			]
		}
	];
	dojo.ready(function() {
		//事件注册
		//新增
		dojo.connect(dijit.byId("btnAdd"), "onClick", function() {
			parent.openDialog({
				id:"messages/add",
				url:"${(path)!}/system/messages.load.do?processType=add",
				title:"新增"
			});
		});
		//编辑
		dojo.connect(dijit.byId("btnEdit"), "onClick", function() {
			var selection = dijit.byId("grid").selection.getSelected();
			if (!selection || selection.length == 0) {
				window.parent.Error("您未选择数据！");
				return;
			}
			var id = store.getValue(selection[0], "id");
			parent.openDialog({
				id: "messages/update",
				url : "${(path)!}/system/messages.load.do?processType=update&messages.id=" + id,
				title : "修改",
				width : 800,
				height : 600
			});
		});
		//查看
		dojo.connect(dijit.byId("grid"), "onRowDblClick", function(e) {
			if (e.rowIndex > -1) {
				var item = dijit.byId("grid").getItem(e.rowIndex);
				if (store.isItem(item)) {
					var id = store.getIdentity(item);
					parent.openDialog({
						id: "messages/View",
						url : "${(path)!}/system/messages.load.do?processType=view&messages.id=" + id,
						title : "查看",
						width : 800,
						height : 600
					})
				}
			}
		});
		//删除
		dojo.connect(dijit.byId("btnDelete"), "onClick", function() {
			var selection = dijit.byId("grid").selection.getSelected();
			if (!selection || selection.length == 0) {
				window.parent.Error("您未选择数据！");
				return;
			}
			var id = store.getValue(selection[0], "id");
			parent.Confirm({
				msg : "确认删除数据吗？",
				okCall : function() {
					dojo.xhrGet({
						url:"${(path)!}/system/messages.delete.do?messages.id=" + id,
						handleAs:"json",
						load:function(json) {
							window.parent.Info("删除成功！", function() {
								dijit.byId("grid").reload();
							});
						}
					})
				}
			})
		});
		//查询
		dojo.connect(dijit.byId("btnQuery"), "onClick", function() {
			dijit.byId("grid").setStore(store, dojo.formToObject("queryForm"));
		});
		//注册响应函数
		parent.subscribe("${(pageId)!}", "messages/refresh", null, function() {
			dijit.byId("grid").reload();
		});
	})
</script>
